// info.cpp
// Customizer
// Protea Customizer / Business Logic for misc. information requests
// Copyright (C) 2003, 2004, 2005 eXegeSys, Inc.
// Copyright (C) 2008 Bruce A. James
//
// This program is part of the Protea Project.
//
// The Protea Project is free software; you can redistribute it and/or modify it 
// under the terms of the GNU General Public License as published by the 
// Free Software Foundation, either version 3 of the License, or (at your 
// option) any later version.
//
// The Protea Project is distributed in the hope that it will be useful, but 
// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
// for more details.
// 
// You should have received a copy of the GNU General Public License along 
// with this program.  If not, see <http://www.gnu.org/licenses/>.
//
// Please send correspondence to:
//
// theproteaproject@gmail.com
//

#include "customizer.h"

//
//@ CHA RevDataTypes
//@ COD RevDataTypes
//@ NUM 190
//@ TAB DATA_TYPE_DEFN Read
//
//@ GEN RevDataTypes returns valid data types
//
TRANSACTION_CODE( RevDataTypes ) {
	XCBuffer* TransBuf = NULL;
	XCDBStatement* stmt = NULL;
	XCField* Data_Type = NULL;
	long dtnum = 0;

	//@ GRS Start the transaction
	START_TXN( RevDataTypes );
		XCSQLGen* query = txnvars.query;

		//@ Create transaction defn buffer
		TransBuf = App->CreateBuffer( FMT_DATA_TYPE_DEFN, true );
		Data_Type = TransBuf->GetField( FLD_DATA_TYPE );

		START_DB_TXN();
			XCOrder ord;

			query->MakeSELECT( TransBuf );
			query->AddORDERBY( FLD_DATA_TYPE, &ord );
			stmt = txnvars.dbtxn->ExecuteSQL( query );

			while (!stmt->Eof()) 
			{
				dtnum = Data_Type->GetLong( true );
				if ( dtnum < 9 || dtnum == 27 || dtnum == 29 || dtnum == 30 || dtnum > 39 )
				{
					App->TransResponse( txnvars.result, TransBuf, TRANS_DETAIL_TYPE );
				}
				stmt->MoveNext();
			};
		END_DB_TXN();

	CLEANUP_TXN();
		App->CleanupObjects( 2, &TransBuf, &stmt );
	END_TXN();
	//@ GRE End the transaction
};















//
//@ CHA RevFormatTypes
//@ COD RevFormatTypes
//@ NUM 190
//@ TAB FMT_TYPE_DEFN Read
//
//@ GEN RevFormatTypes returns valid format types
//
TRANSACTION_CODE( RevFormatTypes ) {
	XCBuffer* TransBuf = NULL;
	XCDBStatement* stmt = NULL;

	//@ GRS Start the transaction
	START_TXN( RevFormatTypes );
		XCSQLGen* query = txnvars.query;

		//@ Create transaction defn buffer
		TransBuf = App->CreateBuffer( FMT_FMT_TYPE_DEFN, true );

		START_DB_TXN();
			XCOrder ord;

			query->MakeSELECT( TransBuf );
			query->AddORDERBY( FLD_FORMAT_TYPE, &ord );
			stmt = txnvars.dbtxn->ExecuteSQL( query );

			while (!stmt->Eof()) {
				App->TransResponse( txnvars.result, TransBuf, TRANS_DETAIL_TYPE );
				stmt->MoveNext();
			};
		END_DB_TXN();

	CLEANUP_TXN();
		App->CleanupObjects( 2, &TransBuf, &stmt );
	END_TXN();
	//@ GRE End the transaction
};
